# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=mesa-demos
pkgver=9.0.0
pkgrel=4
pkgdesc="Mesa demos"
url="https://mesa3d.org"
arch="all"
license="custom"
makedepends="
	freeglut-dev
	glslang-dev
	glu-dev
	libdecor-dev
	libx11-dev
	libxext-dev
	libxkbcommon-dev
	mesa-dev
	meson
	vulkan-loader-dev
	wayland-dev
	wayland-protocols
	"
subpackages="mesa-utils:_utils"
source="https://archive.mesa3d.org/demos/mesa-demos-$pkgver.tar.xz
	glx.patch
	uint.patch
	"
options="!check" # seemingly no way to run the tests

build() {
	# todo: figure out why the size went from ~8.4->34MB
	# (25 with lto), lots of binaries are ~150kb each and same-sized
	abuild-meson \
		-Db_lto=true \
		-Degl=enabled \
		-Dgles1=disabled \
		-Dlibdrm=enabled \
		-Dvulkan=enabled \
		-Dwayland=enabled \
		-Dwith-system-data-files=true \
		-Dx11=enabled \
		. output
	meson compile -C output
}

package() {
	# already big, just pull in the other ones too.
	depends="mesa-utils"
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

check() {
	meson test --print-errorlogs --no-rebuild -C output
}

_utils() {
	pkgdesc="Essential mesa utilities"

	amove \
		usr/bin/eglinfo \
		usr/bin/glxinfo \
		usr/bin/glxgears
}

sha512sums="
af33ef72a521416e39d93370b2b4ccb768f08084c9e4c0aa62868210d9465c858e5cb8e5d23952295a3073946f609eb8723ee60b39dd9fb6696c4e45aafbb2c1  mesa-demos-9.0.0.tar.xz
8622666722d202b6463539098622a2beaac6e6f0bb7c4859b60d1d25b251eb32647051b9d156286a4cf5c575ef80834a9c5bb004a6b990b0baf43040be5e2a92  glx.patch
facaaed1a44090030c1fedda25d408f99e5b940b5a3a54988e0afcde1c3ccd7176121e2ffe25860b97dd86e20cdbff8249f42abda8c8f9d7f8ed2b23bbf7a5b3  uint.patch
"
